<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/BasicTemplate.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Rewired Documentation | Custom Controllers</title>
<!-- InstanceEndEditable -->
<!-- InstanceParam name="isRoot" type="boolean" value="false" -->
<!-- InstanceParam name="wide" type="boolean" value="false" -->
<link href="files/css/styles.css" rel="stylesheet" type="text/css" />
<!-- Favicons -->
<link rel="icon" type="image/x-icon" href="/projects/rewired/files/images/favicon.ico?v=1" />
<!-- Apple Icons -->
<!-- For iPad with high-resolution Retina display running iOS = 7: -->
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="files/images/favicon_152x152.png?v=1">
<!-- For iPad with high-resolution Retina display running iOS = 6: -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="files/images/favicon_144x144.png?v=1">
<!-- For iPhone with high-resolution Retina display running iOS = 7: -->
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="files/images/favicon_120x120.png?v=1">
<!-- For iPhone with high-resolution Retina display running iOS = 6: -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="files/images/favicon_114x114.png?v=1">
<!-- For the iPad mini and the first- and second-generation iPad on iOS = 7: -->
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="files/images/favicon_76x76.png?v=1">
<!-- For the iPad mini and the first- and second-generation iPad on iOS = 6: -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="files/images/favicon_72x72.png?v=1">
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
<link rel="apple-touch-icon-precomposed" href="files/images/favicon_57x57.png?v=1">
</head>

<body>


<div class="container">

    <div class="google-search-bar">
        <script>
          (function() {
            var cx = '007961148920562332911:oocvtwz5jce';
            var gcse = document.createElement('script');
            gcse.type = 'text/javascript';
            gcse.async = true;
            gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
            var s = document.getElementsByTagName('script')[0];
            s.parentNode.insertBefore(gcse, s);
          })();
        </script>
        <gcse:search></gcse:search>
    </div>

  <div class="content">
	
	
	 
    <div class="page-body">
	
    
         
	    
      	<div class="sidebar-nav">
	        <h4><a href="Documentation.html">Documentation</a></h4>
	        <ul>
	          <li><a href="Overview.html">Overview</a></li>
	          <li><a href="ReleaseNotes.txt">Release Notes</a></li>
          </ul>
	        <strong>Essentials:</strong>
            <ol>
              <li><a href="Installation.html">Installation</a></li>
              <li><a href="QuickStart.html">Quick Start</a></li>
              <li><a href="BasicUsage.html">Basic Usage</a></li>
              <li><a href="Deployment.html">Deployment</a></li>
              <li><a href="BestPractices.html">Best Practices</a></li>
              <li><a href="RewiredEditor.html">Rewired Editor</a></li>
              <li><a href="https://guavaman.com/projects/rewired/docs/api-reference" target="_blank">API Reference</a></li>
            </ol>
            <strong>Concepts:</strong>
            <ul>
              <li><a href="InputManager.html">Input Manager</a></li>
              <li><a href="Players.html">Players</a></li>
              <li><a href="Actions.html">Actions</a></li>
              <li><a href="InputBehaviors.html">Input Behaviors</a></li>
              <li><a href="Controllers.html">Controllers</a></li>
              <li><a href="ControllerMaps.html">Controller Maps</a></li>
              <li><a href="ControllerTemplates.html">Controller Templates</a></li>
              <li><a href="MapCategories.html">Map Categories</a></li>
              <li><a href="Layouts.html">Layouts</a></li>
              <li><a href="LayoutManager.html">Layout Manager</a></li>
              <li><a href="MapEnabler.html">Map Enabler</a></li>
              <li><a href="CustomControllers.html">Custom Controllers</a></li>
            </ul>
            <strong>Extras:</strong>
            <ul>
              <li><a href="ControlMapper.html" title="Control Mapper">Control Mapper</a></li>
	          <li><a href="TouchControls.html" title="Touch Controls">Touch Controls</a></li>
              <li><a href="RewiredStandaloneInputModule.html">Rewired Standalone Input Module</a></li>
	          <li><a href="UnityInputOverride.html" title="Unity Input Override">Unity Input Override</a></li>
            </ul>
            <strong>Misc:</strong>
            <ul>
	          <li><a href="ComponentControls.html" title="Component Controls">Component Controls</a></li>
	          <li><a href="PlayerControllers.html" title="Player Controllers">Player Controllers</a></li>
	          <li><a href="InputMapper.html" title="Input Mapper">Input Mapper</a></li>
	          <li><a href="UserDataStore.html" title="User Data Store">User Data Store</a></li>
            </ul>
            <strong>How To's:</strong>
            <ul>
            	<li><a href="HowTos.html">See all topics...</a></li>
            </ul>
            <strong>Help:</strong>
            <ul>
              <li><a href="SupportedControllers.html" title="Supported Controllers">Supported Controllers</a></li>
              <li><a href="Overview.html#tested-platforms" title="Tested Platforms">Tested Platforms</a></li>
              <li><a href="Troubleshooting.html" title="Troubleshooting">Troubleshooting</a></li>
              <li><a href="KnownIssues.html">Known Issues</a></li>
              <li><a href="SpecialPlatformSupport.html" title="Special Platform Support">Special Platform Support</a></li>
	          <li><a href="Examples.html" title="Examples">Examples</a></li>
              <li><a href="Integration.html">Integrations</a></li>
	          <li><a href="Updating.html" title="Updating Rewired">Updating Rewired</a></li>
            </ul>
            <strong>FAQ</strong>
            <ul>
            	<li><a href="FAQ.html">See all topics...</a></li>
            </ul>
            <strong>Unity Help:</strong>
            <ul>
              <li><a href="https://docs.unity3d.com/Manual/" target="_blank">Unity Manual</a></li>
              <li><a href="https://docs.unity3d.com/ScriptReference/" target="_blank">Unity Script Reference</a></li>
              <li><a href="https://unity3d.com/learn/tutorials/modules" target="_blank">Unity Tutorials</a></li>
            </ul>
            <strong>Links:</strong>
            <ul>
              <li><a href="https://guavaman.com/projects/rewired">Rewired Website</a></li>
              <li><a href="https://guavaman.com/projects/rewired/docs">Web Documentation</a></li>
            </ul>
        </div>
        
    
    	<div class="main-body">
	        <div class="logo"><a href="https://guavaman.com/projects/rewired" title="Rewired"><img src="files/images/rewired-logo.png" width="173" height="139" alt="Rewired" /></a></div>
                     
            <h1>
            <!-- InstanceBeginEditable name="PageHeader" -->Custom Controllers
      <!-- InstanceEndEditable -->
            </h1>
            
			<!-- InstanceBeginEditable name="MainBody" -->

    <p>Custom Controllers are a type of virtual controller that you can customize, adding as many axes and buttons as you need. A Custom Controller allows you to set your own sources for axis and button input. This could be any type of physical or virtual controller. Anything that can return a float or a boolean value can be used as an element source. Custom Controllers can be used for on-screeen touch controllers and more. (See the example in the Rewired/Examples folder.)</p>
    <p><strong>IMPORTANT NOTE:</strong> Custom Controllers are NOT meant to be used to create new HID joystick definitions for controllers that Rewired doesn't automatically recognize and map for you. They are virtual controllers that  know nothing but what axis and button data is fed into them by your script. They are entirely separate from the Joystick system, are not auto-assigned, don't generate connect or disconnect events, etc. If you are planning to use a Custom Controller to add support for controller that Rewired can detect but doesn't recognize and automatically map for you, don't -- it's the wrong tool for the job. Instead you want to <a href="HowTos.html#new-controller-definitions">create a new controller definition</a> for that or else define a Joystick Map for <a href="ControllerMaps.html#unknown-controllers">Unknown Controller</a> instead. Custom Controllers can however be used to support  devices that  do not show up as joysticks such as special controllers that require the use of an  SDK (most VR controllers).</p>
    <p><strong>Creating/Editing Custom Controllers</strong></p>
<p>You create and edit Custom Controllers in the <a href="RewiredEditor.html">Rewired Editor</a>. See <a href="RewiredEditor.html#CustomControllers">Rewired Editor - Custom Controllers</a> for more information.</p>
<p><strong>Assigning Custom Controllers to Players </strong></p>
<p>You assign starting Custom Controllers in the <a href="RewiredEditor.html">Rewired Editor</a>. See <a href="RewiredEditor.html#Players">Rewired Editor - Players</a> for more information.</p>
<p>Custom Controllers, unlike Joysticks, are instantiated for each player. When you add a Custom Controller, the controller will be created on game start and assigned to the Player. If you add the same controller to multiple Players, the Custom Controller will be instantiated for each, therefore setting a Tag on each can be helpful to differentiate the controllers.</p>
<p>You can also assign and un-assign Custom Controllers via scripting at runtime. This can be useful if you want to detect the presence of a certain type of non-standard controller (some VR controller for example) and auto-assign that to a Player. Assignment of Custom Controllers is <a href="HowTos.html#assigning-joysticks">similar to assigning Joysticks to Players</a>.</p>
<p><strong>Instantiating Custom Controllers via scripting</strong></p>
<p>Normally, Rewired will instantiate the controllers assigned to each Player upon initialization. If you need to instantiate new Custom Controller objects at runtime, they can be instantiated from the pre-defined definitions in the Rewired Input Manager at via scripting using the <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_ReInput_ControllerHelper.htm">CreateCustomController methods in ReInput.controllers</a>.</p>
<p><strong>Updating Element Values</strong></p>
<p>Element (axes and buttons) values must be updated on the Custom Controller each frame. There are 2 different ways you can do this:</p>
<p>1) Register for the <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/E_Rewired_ReInput_InputSourceUpdateEvent.htm">ReInput.InputSourceUpdateEvent</a>, then when that event fires, push the new values into the elements directly through <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/Overload_Rewired_CustomController_SetAxisValue.htm">CustomController.SetAxisValue</a> and <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/Overload_Rewired_CustomController_SetButtonValue.htm">CustomController.SetButtonValue</a>.</p>
<p>2) Set callbacks in the CustomController with <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/M_Rewired_CustomController_SetAxisUpdateCallback.htm">CustomController.SetAxisUpdateCallback</a> and <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/M_Rewired_CustomController_SetButtonUpdateCallback.htm">SetButtonUpdateCallback</a>. These callback functions will be called during the input update step and you can push the latest values into the element at this time.</p>
<p>Examples of both methods can be seen in the Touch Controller example in the Rewired/Examples folder.</p>
<p>Note: Both the <a href="https://guavaman.com/projects/rewired/docs/api-reference/html/E_Rewired_ReInput_InputSourceUpdateEvent.htm">InputSourceUpdateEvent</a> and the callbacks may be called more than once per frame. They will be called each time input is updated, which is dependent on the Update Loop setting in the Input Manager. If you're updating input in multiple loops, for example Update and FixedUpdate, the event and the callbacks will be called once for each update loop.</p>
<p><strong>Examples</strong></p>
<ul>
  <li><a href="Examples.html#custom-controllers-touch">Custom Controllers Touch</a></li>
  <li><a href="Examples.html#custom-controllers-tilt">Custom Controllers Tilt</a></li>
</ul>
<div class="bottom-pager clearfix">
  <a class="back-button" href="ControllerTemplates.html" title="Layouts"><span class="button-img"></span>Controller Templates</a>
  <a class="forward-button" href="HowTos.html" title="How To's"><span class="button-img"></span>How To's</a>
</div>
<!-- InstanceEndEditable -->
        </div>
        
    </div>
  <div class="footer clearfix">
   	<p class="left">Copyright &copy;2014-2021 <a href="https://guavaman.com" title="Guavaman Enterprises">Guavaman Enterprises</a>. All rights reserved. No materials may be reproduced without permission.</p>
  	<p class="right"><a href="https://guavaman.com/projects/rewired" title="Return to Rewired Website">Return to Rewired Website</a></p>
  </div>
  <!-- end .content --></div>
  <!-- end .container --></div>
  
  
</body>
<!-- InstanceEnd --></html>
